//
//  MoBanElevenViewController.m
//  MoBan
//
//  Created by apple on 16/7/25.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MoBanElevenViewController.h"
#import "MoBanElevenAllSelect.h"
#import "MoBanElevenTableviewCell.h"
#import "MoBanElevenModel.h"
@interface MoBanElevenViewController ()<UITableViewDataSource,UITableViewDelegate,MoBanElevenAllSelectDeleget>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)MoBanElevenAllSelect *allselectview;
/**
 盛放模型的数组
 */
@property(nonatomic,strong)NSMutableArray *array;
@end

@implementation MoBanElevenViewController
-(NSMutableArray *)array
{
    if (!_array) {
        _array = [NSMutableArray array];
    }
    return _array;
}
-(MoBanElevenAllSelect *)allselectview
{
    if (!_allselectview) {
        _allselectview  =[[MoBanElevenAllSelect alloc]initWithFrame:CGRectMake(0, KscrH, KscrW, 40*Kscr)];
        
        NSLog(@"%f/////%f",KscrH,self.view.height);
        
        _allselectview.backgroundColor = [UIColor whiteColor];
        _allselectview.deleget = self;
    }
    return _allselectview;

}
-(UITableView *)tableview
{
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KscrW, KscrH-KBar1)];
        _tableview.dataSource = self;
        _tableview.delegate = self;
        _tableview.rowHeight = 80*Kscr;
    }
    return _tableview;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableview];
    [self.view addSubview:self.allselectview];
    [self addtarget:self witiTItle:@"编辑" with:@selector(changefram)];
    
    for ( NSInteger i=0; i<20; i++) {
        MoBanElevenModel *model= [[MoBanElevenModel alloc]init];
        [self.array addObject:model];
    }
    
    // Do any additional setup after loading the view.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MoBanElevenTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MoBanElevenTableviewCell"];
    if (!cell) {
        cell = [[MoBanElevenTableviewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MoBanElevenTableviewCell"];
    }
    [cell ZBdatasouce:self.array[indexPath.row]];
    return cell;

}
-(void)ZBallSelect:(UIButton *)butten
{
    NSArray *array = [self.tableview visibleCells];
    for (MoBanElevenTableviewCell *cell in array) {
        [cell ZBCellBtnSelected:butten];
    }
    
    
    for (MoBanElevenModel *model in self.array) {
        
        model.selected = butten.selected;
    }
    
    

}
-(void)changefram
{
    if (self.allselectview.top>=KscrH) {
        self.allselectview.transform = CGAffineTransformMakeTranslation(0, -KBar1-40*Kscr);
    }else
    {
        self.allselectview.transform = CGAffineTransformMakeTranslation(0, 0);

    }
}
@end
